import request from '@/router/axios'

export function fetchList(query) {
  return request({
    url: '/ceo-user/role',
    method: 'get',
    params: query
  })
}

export function getObj(id) {
  return request({
    url: '/ceo-user/role/' + id,
    method: 'get'
  })
}

export function addObj(obj) {
  return request({
    url: '/ceo-user/role',
    method: 'post',
    data: obj
  })
}

export function putObj(obj) {
  return request({
    url: '/ceo-user/role',
    method: 'put',
    data: obj
  })
}

export function toggleObj(id, enable) {
  return request({
    url: '/ceo-user/role/' + id + '/' + enable,
    method: 'get'
  })
}

export function permissionUpdate(roleId, permissionIds) {
  return request({
    url: '/ceo-user/permission/role/' + roleId,
    method: 'put',
    data: permissionIds
  })
}

export function permitRoleUpdate(roleId, roleIds) {
  return request({
    url: '/ceo-user/role/permit/' + roleId,
    method: 'put',
    data: roleIds
  })
}

export function fetchPermitRole(roleId) {
  return request({
    url: '/ceo-user/role/permit/' + roleId,
    method: 'get'
  })
}

export function fetchPermission(roleId) {
  return request({
    url: '/ceo-user/permission/role/' + roleId,
    method: 'get'
  })
}

export function fetchAllPermitRole() {
  return request({
    url: '/ceo-user/role/permit',
    method: 'get'
  })
}

export function fetchAllPermission() {
  return request({
    url: '/ceo-user/permission',
    method: 'get',
    params: {
      page: 1,
      limit: 9999
    }
  })
}
